package com.xyy.saas.payment.payment.core.service;

import com.xyy.saas.payment.dao.mapper.RefundOrderMapper;
import com.xyy.saas.payment.dao.model.RefundOrder;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;

@Service
public class RefundOrderService {
    @Resource
    private RefundOrderMapper refundOrderMapper;

    public Integer queryTotalRefundAmount(String payNo) {
        return refundOrderMapper.queryTotalRefundAmount(payNo);
    }

    public List<RefundOrder> selectListByPayNo(String payNo) {
        return refundOrderMapper.selectListByPayNo(payNo);
    }

    public RefundOrder selectByRefundNo(String refundNo) {
        return refundOrderMapper.selectByRefundNo(refundNo);
    }

    /**
     * 根据渠道和状态查询
     */
    public List<RefundOrder> selectListByStatusAndPayChannel(String payChannel, Byte status, Integer pageOffset, Integer pageSize) {
        return refundOrderMapper.selectListByStatusAndPayChannel(payChannel, status, pageOffset, pageSize);
    }

    public List<RefundOrder> queryPinganCreditListByTime(LocalDateTime beginTime, LocalDateTime endTime) {
        if (beginTime == null || endTime == null) {
            return Collections.emptyList();
        }
        return refundOrderMapper.queryPinganCreditListByTime(beginTime, endTime);
    }

    public void update(RefundOrder refundOrder) {
        refundOrderMapper.updateByPrimaryKeySelective(refundOrder);
    }

    public RefundOrder selectByBusinessRefundNo(String businessRefundNo) {
        return refundOrderMapper.selectByBusinessRefundNo2(businessRefundNo);
    }
}
